import http from './interface';

// 获取短信
export const sendCode = data => {
    return http.request({
        url: '/app/auth-code',
        method: 'POST',
        data,
        // handle:true
    });
};

// 登录
export const login = data => {
    return http.request({
        url: '/app/login',
        method: 'POST',
        data,
        // handle:true
    });
};
// 登录验证码
export const loginCode = data => {
    return http.request({
        url: '/app/captcha',
        method: 'POST',
        data,
        // handle:true
    });
};
// 退出登录
export const logout = data => {
    return http.request({
        url: '/app/logout',
        method: 'POST',
        data,
        // handle:true
    });
};
// 注册
export const register = data => {
    return http.request({
        url: '/app/register',
        method: 'POST',
        data,
        // handle:true
    });
};

// 找回密码
export const forgetpwd = data => {
    return http.request({
        url: '/app/forgetpwd',
        method: 'POST',
        data,
        // handle:true
    });
};

/*
 *
 * 首页
 */
export const getHomeInfo = data => {
    return http.request({
        url: '/app/contract/index',
        method: 'POST',
        data,
        // handle:true
    });
};
//  首页公告
export const getArt = data => {
    return http.request({
        url: '/app/member/getart',
        method: 'POST',
        data,
        // handle:true
    });
};

// 购买矿机
export const buyMine = data => {
    return http.request({
        url: '/app/contract/buymine',
        method: 'POST',
        data,
        // handle:true
    });
};
/*
 *
 * 我的矿机
 */
export const myMine = data => {
    return http.request({
        url: '/app/contract/mymine',
        method: 'POST',
        data,
        // handle:true
    });
};
// 一键领取
export const getMyMine = data => {
    return http.request({
        url: '/app/contract/recenums',
        method: 'POST',
        data,
        // handle:true
    });
};

/*
 *
 * 交易大厅
 */
// 买单列表
export const getBuyList = data => {
    return http.request({
        url: '/app/trade/buylist',
        method: 'POST',
        data,
    });
};
// 卖单列表
export const getSellList = data => {
    return http.request({
        url: '/app/trade/selllist',
        method: 'POST',
        data,
    });
};
// 当前价格
export const getUnitPrice = data => {
    return http.request({
        url: '/app/trade/unit-price',
        method: 'POST',
        data,
    });
};
// 七次价格变动
export const getSevenDayUnitPrice = data => {
    return http.request({
        url: '/app/trade/price-rec',
        method: 'POST',
        data,
    });
};
// 买入
export const MGCbuy = data => {
    return http.request({
        url: '/app/trade/buy',
        method: 'POST',
        data,
    });
};
// 卖出
export const MGCsell = data => {
    return http.request({
        url: '/app/trade/sell',
        method: 'POST',
        data,
    });
};
// 买入、卖出数量选择
export const MGCmesllnums = data => {
    return http.request({
        url: '/app/trade/mesllnums',
        method: 'POST',
        data,
    });
};

// 获取我的待交易的买单
export const myBuy = data => {
    return http.request({
        url: '/app/trade/mybuying',
        method: 'POST',
        data,
    });
};
// 获取我的正在交易或者交易完成的买单
export const myBuyIng = data => {
    return http.request({
        url: '/app/trade/mybought',
        method: 'POST',
        data,
    });
};

// 获取我的待交易的卖单
export const mySell = data => {
    return http.request({
        url: '/app/trade/myonsell',
        method: 'POST',
        data,
    });
};
// 获取我的正在交易或者交易完成的卖单
export const mySellIng = data => {
    return http.request({
        url: '/app/trade/mysold',
        method: 'POST',
        data,
    });
};
// 撤销订单
export const calloff = data => {
    return http.request({
        url: '/app/trade/calloff',
        method: 'POST',
        data,
    });
};

// 详情页面
export const tradeDetail = data => {
    return http.request({
        url: '/app/trade/trade-detail',
        method: 'POST',
        data,
    });
};

// 投诉挂卖单
export const delorder = data => {
    return http.request({
        url: '/app/trade/delorder',
        method: 'POST',
        data,
    });
};

// 确定收款
export const receive = data => {
    return http.request({
        url: '/app/trade/receive',
        method: 'POST',
        data,
    });
};

// 举报假截图
export const comtrading = data => {
    return http.request({
        url: '/app/trade/comtrading',
        method: 'POST',
        data,
    });
};

/*
 *
 * 个人中心
 */
export const getUserInfo = data => {
    return http.request({
        url: '/app/member/mdata',
        method: 'POST',
        data,
        // handle:true
    });
};
// 签到
export const getSign = data => {
    return http.request({
        url: '/app/member/sign',
        method: 'POST',
        data,
    });
};

// 实名认证
export const realName = data => {
    return http.request({
        url: '/app/member/realname',
        method: 'POST',
        data,
    });
};

// 每日释放
export const dayKrprice = data => {
    return http.request({
        url: '/app/member/daykrprice',
        method: 'POST',
        data,
    });
};
// 可售余额兑换--钱包
export const immExchange = data => {
    return http.request({
        url: '/app/member/immExchange',
        method: 'POST',
        data,
    });
};
// 钱包转--资产
export const saveKprice = data => {
    return http.request({
        url: '/app/member/savekprice',
        method: 'POST',
        data,
    });
};

// 修改登录密码
export const resetPwd = data => {
    return http.request({
        url: '/app/member/editpwd',
        method: 'POST',
        data,
    });
};

// 修改交易密码
export const resetTPwd = data => {
    return http.request({
        url: '/app/member/editpwds',
        method: 'POST',
        data,
    });
};

// 账户解封
export const myUnban = data => {
    return http.request({
        url: '/app/member/somember',
        method: 'POST',
        data,
    });
};

// 财务明细
export const priceDatail = data => {
    return http.request({
        url: '/app/member/priceDatail',
        method: 'POST',
        data,
    });
};

// // 活动列表
// export const getActivityList = data => {
//     return http.request({
//         url: '/app/member/getact',
//         method: 'POST',
//         data,
//     });
// };

// 活动列表
export const getActivityList = data => {
    return http.request({
        url: '/app/trade/getacttwo',
        method: 'POST',
        data,
    });
};
export const getacttwobefore = data => {
    return http.request({
        url: '/app/trade/getacttwobefore',
        method: 'POST',
        data,
    });
};

// 活动列表 领取
export const handleActiviytwo = data => {
    return http.request({
        url: '/app/trade/handleActiviytwo',
        method: 'POST',
        data,
    });
};

// 领取活动奖励
export const getActivityAward = data => {
    return http.request({
        url: '/app/member/giveart',
        method: 'POST',
        data,
    });
};
// 直推奖励列表
export const getActivityDirectList = data => {
    return http.request({
        url: '/app/contract/fiveoneactivity',
        method: 'POST',
        data,
    });
};

// 领取直推奖励
export const getActivityDirectAward = data => {
    return http.request({
        url: '/app/contract/getfiveonereward?level=' + data.level,
        method: 'POST',
        data,
    });
};

// 团队人数
export const getTeamNum = data => {
    return http.request({
        url: '/app/member/teamnum',
        method: 'POST',
        data,
    });
};

// 累计奖金
export const getJackpot = data => {
    return http.request({
        url: '/app/member/jackpot',
        method: 'POST',
        data,
    });
};

// 累计收益
export const getAccumincome = data => {
    return http.request({
        url: '/app/member/accumincome',
        method: 'POST',
        data,
    });
};

// 检查更新
export const update = data => {
    return http.request({
        url: '/app/update',
        method: 'POST',
        data,
    });
};

// 意见反馈
export const feedback = data => {
    return http.request({
        url: '/app/member/feedback',
        method: 'POST',
        data,
    });
};

/*
 * 上传图片
 *
 */
export const upload_one = (url, data) => {
    try {
        const value = uni.getStorageSync('STOREKEY_LOGIN');
        if (value) {
            const _token = value || 'undefined';
            return new Promise((resolve, reject) => {
                uni.showLoading({
                    title: '上传中',
                });
                uni.uploadFile({
                    url: http.config.baseUrl + url,
                    filePath: data.upfile,
                    header: {
                        'x-app-token': _token,
                    },
                    name: 'file',
                    formData: data,
                    success: uploadFileRes => {
                        if ('string' === typeof uploadFileRes) {
                            resolve(JSON.parse(uploadFileRes));
                        } else {
                            resolve(uploadFileRes);
                        }
                    },
                    complete() {
                        uni.hideLoading();
                    },
                });
            });
        }
    } catch (e) {
        // error
    }
};

export default {
    sendCode, // 登录、注册
    login,
    loginCode,
    logout,
    register,
    forgetpwd,
    getHomeInfo, // 首页
    getArt,
    buyMine,
    myMine, // 我的矿机
    getMyMine,
    getBuyList, // 交易大厅
    getSellList,
    getUnitPrice,
    getSevenDayUnitPrice,
    MGCbuy,
    MGCsell,
    MGCmesllnums,
    myBuy,
    myBuyIng,
    mySell,
    mySellIng,
    tradeDetail,
    delorder,
    comtrading,
    receive,
    calloff,
    getUserInfo, // 用户中心
    getSign,
    upload_one,
    dayKrprice,
    immExchange,
    saveKprice,
    resetPwd,
    resetTPwd,
    myUnban,
    priceDatail,
    getActivityList,
	getacttwobefore,
	handleActiviytwo,
    getActivityAward,
    getActivityDirectList,
    getActivityDirectAward,
    update,
    feedback,
    getTeamNum,
    getJackpot,
    getAccumincome,
};
